﻿Imports QueComer

Public Class LoginWeb
    Inherits System.Web.UI.Page

    Dim rest As String

    Protected Sub LoginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LoginButton.Click
        Dim negocio As New Login
        Dim us = UserName.Text
        Dim pw = Password.Text
        Try
            Dim modelo = negocio.validar(us, pw)
            Dim name = modelo.nombre
            Dim rolex = modelo.rol

            If Constantes.ADMIN = rolex Then

                FormsAuthentication.RedirectFromLoginPage(name, RememberMe.Checked)

            ElseIf Constantes.ADM_REST = rolex Then

                Dim rest = modelo.restaurante
                FormsAuthentication.RedirectFromLoginPage(name, RememberMe.Checked)
                Session("nrst") = rest
                Response.Redirect("Default.aspx")
            Else

                FormsAuthentication.RedirectFromLoginPage(name, RememberMe.Checked)

            End If
        Catch ex As Exception
            InvalidCredentialsMessage.Visible = True
        End Try
    End Sub


End Class